package com.whfp.coky.ui.task.act.fluor

import android.content.Context
import android.os.Bundle
import android.view.View
import com.whfp.coky.R
import com.whfp.coky.databinding.ItemSbBinding
import com.whfp.coky.databinding.RecycleTitleViewBinding
import com.whfp.coky.db.dao.ProjectSettingDao
import com.whfp.coky.other.Constants
import com.whfp.coky.ui.base.BaseAdapter
import com.whfp.coky.ui.base.BaseRecycleAct
import com.whfp.coky.ui.task.vm.fluor.ThresholdListVM


class ThresholdListAct : BaseRecycleAct<ThresholdListVM, RecycleTitleViewBinding, ProjectSettingDao>(){

    override fun initAdapter(context: Context) = ThresHoldAdapter(context)

    override fun initRecycler() = vBinding.recyclerView

    override fun initRefreshLayout() = vBinding.refreshLayout


    override fun initView() {
        super.initView()
        setTitle("项目阈值设置")
        setRightIcon(R.mipmap.icon_add_gray)
    }

    override fun onRightClick(view: View) {
        super.onRightClick(view)
        startActivity(ThresholdDetailAct::class.java)
    }

    override fun itemClick(pos: Int) {
        startActivity(ThresholdDetailAct::class.java, Bundle().apply {
            putInt(Constants.ID,vModel.mAdapter!!.getItem(pos).id)
        })
    }

    inner class ThresHoldAdapter(context: Context) : BaseAdapter<ItemSbBinding, ProjectSettingDao>(context){
        override fun convert(v: ItemSbBinding, t: ProjectSettingDao, position: Int) {
            v.itemSb.setLeftText(t.projectName)
        }
    }
}